package com.distributer.report.infrastructure.mq;

public class KafkaData {
	
	private final int partition;
	
	private final String key;
	
	private final long offset;
	
	private final String data;
	
	private final String topic;
	
	private final long timestamp;
	
	private final String messageId;
	
	private int retryCount;
	

	public KafkaData(int partition, long offset, String data,String key,String topic,long timestamp) {
		this.partition = partition;
		this.offset = offset;
		this.data = data;
		this.key = key;
		this.topic = topic;
		this.timestamp = timestamp;
		this.messageId = new StringBuilder(this.topic).append(":").append(this.key).append(":").append(timestamp).toString();
		this.retryCount = 0;
	}
	
	public String getMessageId(){
		return this.messageId;
	}

	public int getPartition() {
		return partition;
	}

	public long getOffset() {
		return offset;
	}

	public String getData() {
		return data;
	}

	public String getKey() {
		return key;
	}

	public String getTopic() {
		return topic;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public int getRetryCount() {
		return retryCount;
	}

	public void setRetryCount(int retryCount) {
		this.retryCount = retryCount;
	}
	
	public void increment(){
		this.retryCount = retryCount + 1;
	}

	public boolean arriveMaxRetryCount() {
		return this.retryCount == 3;
	}
	
}
